{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    {include file="nav" /}
<div class="toptip">
    <h2>提示：</h2>
    <p style="color:red">
      保存后，将获取共享题库所有数据<br>
    </p>
</div>
 <legend><i class="Hui-iconfont">&#xe600;</i>共享题库</legend>
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
		<!--<div class="row cl">-->
            <!--<label class="form-label  f-l ml-20">题库名：</label>-->
            <!--<div class="formControls col-xs-8 col-sm-5">-->
                <!--<input type="text" class="input-text" placeholder="题库名" name="name" value="{$vo.name ?? ''}" datatype="*" nullmsg="请输入题库名称，题库名称不能为空">-->
            <!--</div>-->
            <!--<div class="col-xs-offset-4"></div>-->
        <!--</div>-->
        <div class="row cl">
            <label class="form-label  f-l ml-20">上级共享题库：</label>
            <div class="formControls  col-xs-8 col-sm-5">
                <div class="select-box">
                    <select name="parentid" class="select" datatype="*" nullmsg="请选择所属上级题库" >
						<option value=""  >请选择一个题库</option>
                        {volist name='qbanks' id='st'}
                        <option value="{$st.id}"  >{$st.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="col-xs-offset-4"></div>
        </div>	


       <div class="row cl">
            <div class="ml-save">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;保存&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<style>
    .paper-rule i{
        font-style: normal;
        color: #f00;
        font-size: 12px;
    }
</style>
<script>
    function writeRule() {
        var data_rule = [];
        $('#ruleShow p').each(function () {
            data_rule.push($(this).attr('data-rule'));
        });
        $('#data_rule').val(data_rule);
    }
    $(document).ready(function(){
        common();
        $("#paperAdd").on("click", function(){
            var secs_3Text = $("#secs_3 option:selected").text();
            var know_3 = $("#know_3 option:selected").val();
            var know_3Text = $("#know_3 option:selected").text();
            var p_setting_3 = $("#p_setting_3 option:selected").val();
            var p_setting_3Text = $("#p_setting_3 option:selected").text();
            var num = $("#p_setting_4").val();
            var score = $("#sett_3").val();
            var rule = "";
            var total = 0;
            var html = "";
            console.log(know_3);
            console.log(p_setting_3);
            console.log(num);
            console.log(score);
            if(know_3 && p_setting_3 && num && score) {
                rule = know_3 + ":" + p_setting_3 + ":" + num + ":" + score;
                total = parseInt(num)*parseInt(score);
                var ruleString = secs_3Text + know_3Text + p_setting_3Text + num + "道,每题" + score + "分";

                html = "<p class='paper-rule' data-total='" + total
                            + "' data-rule='" + rule
                        + "'>" + ruleString
                        + "<i onclick='deleteRule(this);'>删除</i></p>";
                $("#ruleShow").append(html);
                writeRule();
            }else{
                layer_msg = layer.msg('规则不正确…', {time: 2000});
                return false;
            }
        })
    });
    function getToalScore() {
        var total = 0;
        $('#ruleShow p').each(function () {
            total +=parseInt($(this).attr('data-total'));
        });
        return total;
    }
    function deleteRule(obj){
        $(obj).parent().remove();
        writeRule();
    }
</script>
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {
        $("[name='status'][value='{$vo.status ?? ''}']").prop("checked", true);

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: false,
            callback: function (ret){
                ajax_progress(ret);
            }
        });
    })
</script>
{/block}
